/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable react/jsx-pascal-case */
import React from "react";
import { Fire, FireO } from '@react-vant/icons'
const Info = () => {
    let navigate = React.$router.useNavigate();
    // 获取路由传参的方法
    let [searchParams] = React.$router.useSearchParams();
    // 获取路由传参的ID值
    const [id, setId] = React.useState(searchParams.get('leaseid'))
    const [LoginUser, setLoginUser] = React.useState(React.$LoginUser ? React.$LoginUser : {})
    const [info, setInfo] = React.useState({
        product: {},
        business: {}
    })

    React.useEffect(() => {
        getInfoData()
    }, [id])

    const getInfoData = async () => {
        let data = {
            id: id,
            busid: LoginUser.id
        }

        let result = await React.$api.leaseinfo(data)
        if (result && result.code == 1) {
            setInfo(result.data)
            console.log(result.data)
        }
    }
    // 拔打客服电话
    const ToContact = () => {
        window.location.href = `tel: ${info.tel}`
    }

    // 物流信息
    const Expressquery = () => {
        if (info.expcode) {
            return (
                <>
                    <li>物流公司名称：<span>{info.expid_text}</span></li>
                    <li>物流单号：<span>{info.expcode}</span></li>
                </>
            )
        }
    }

    // 评论信息
    const Comment = () => {
        if (info.rate) {
            return (
                <>
                    <li>评分：
                        <React.$Vant.Rate
                            icon={<Fire />}
                            voidIcon={<FireO />}
                            value={info.rate}
                            readOnly	
                        />
                    </li>
                    <li>评价内容：
                    <React.$Vant.Input.TextArea  defaultValue={info.comment} readOnly/>
                    </li>
                </>
            )
        }
    }

    return (
        <>
            <React.$Vant.NavBar
                title="订单详情"
                onClickLeft={() => navigate('/business/lease/index')}
            />
            <div className="zy_module_content">
                <div className="swiper-container vip_user_order">

                    <div className="swiper-slide">
                        <ul>
                            <li style={{ borderBottom: 'none' }}>
                                <div className="vip_order_goods">
                                    <h3>
                                        <React.$router.NavLink to={`/business/product/info?pid=${info.proid}`}>
                                            <i><img src={info.product.thumbs_text} /></i>
                                            <dl>
                                                <dt>{info.product.name}</dt>
                                                <dd>
                                                    <em>押金</em>
                                                    <em>{info.rent}</em>
                                                </dd>
                                                <dd>
                                                    <em>总价</em>
                                                    <em>{info.price}</em>
                                                </dd>
                                                <dd>
                                                    <em>结束时间</em>
                                                    <em>{info.endtime_text}</em>
                                                </dd>
                                                <dd>
                                                    <em>订单状态</em>
                                                    <em>{info.status_text}</em>
                                                </dd>
                                            </dl>
                                        </React.$router.NavLink>
                                    </h3>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div className="lianxi_ge">
                <div onClick={ToContact}>联系客服</div>
            </div>
            <div className="rem2"></div>
            <div className="xiangq_xiaox">
                <ul>
                    <li>联系人：<span>{info.business.nickname}</span></li>
                    <li>性别：<span>{info.business.gender_text}</span></li>
                    <li>联系电话：<span>{info.business.mobile}</span></li>
                    <li>下单时间：<span>{info.createtime}</span></li>
                    <li className="no">支付方式：<span>在线支付</span></li>
                    {/* 物流信息，评论 */}
                    <Expressquery />
                    <Comment/>
                </ul>
            </div>
            <div className="rem2"></div>
            <div className="nimen_er">
                <p>证件照片</p>
                <div className="card_text">
                    <img src={info.card_text} alt="" />
                </div>
            </div>
            <div className="rem2"></div>
            <div className="xq_money">
                <p>押金<span className="color">￥{info.rent}</span></p>
                <p>租金<span>+{info.price - info.rent}</span></p>
                <div>
                    <p><span>合计：<b className="color">￥{info.price}</b></span></p>
                </div>
            </div>
        </>
    )
}

export default Info;